package VN.EDU.IMIC.DEVELOPER.VUVANLUANSWINGJTABLEJSON;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class BangthemXML_JSON_SQL extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BangthemXML_JSON_SQL frame = new BangthemXML_JSON_SQL();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BangthemXML_JSON_SQL() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnNewButton = new JButton("SQL");
		btnNewButton.setBounds(29, 164, 89, 23);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("XML");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//them du lieu XML

                JFileChooser objFile = new JFileChooser();
                objFile.setCurrentDirectory(new java.io.File("."));
                objFile.setDialogTitle("Chọn file: ");
                objFile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                String[] EXTENSION = new String[] { "xml" };
                FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files", EXTENSION);
                objFile.setFileFilter(filter);
                objFile.setMultiSelectionEnabled(false);

                int returnVal = objFile.showOpenDialog(null);
                String ParentPath = "";
                String FileName = "";
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    ParentPath = objFile.getSelectedFile().getParent();
                    FileName = objFile.getSelectedFile().getName();
                    JOptionPane.showMessageDialog(getParent(), "Files: " + FileName);
                }
			}
		});
		btnNewButton_1.setBounds(170, 164, 89, 23);
		contentPane.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("JSON");
		btnNewButton_2.setBounds(309, 164, 89, 23);
		contentPane.add(btnNewButton_2);
		
		JLabel lblBnMunThm = new JLabel("Bạn muốn thêm File bằng kiểu file nào ? Xin mời chọn !!");
		lblBnMunThm.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblBnMunThm.setBounds(29, 21, 369, 70);
		contentPane.add(lblBnMunThm);
	}

}
